package com.atguigu.juc.study.chapter14.rwlock;

/**
 * @author : leimingchao
 * @date Date : 2022年06月22日 6:39
 */
public class ReentrantReadWriteLockDemo {

    public static void main(String[] args) {

        MyResource myResource = new MyResource();

        for (int i = 1; i <= 10; i++) {

            int finalI = i;
            new Thread(() -> {
                myResource.write(finalI + "", finalI + "");
            }, String.valueOf(i)).start();
        }


        for (int i = 1; i <= 10; i++) {

            int finalI = i;
            new Thread(() -> {
                myResource.read(finalI + "");
            }, String.valueOf(i)).start();
        }
    }
}
